const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const rootPath = path.resolve(__dirname, '../');

function resolve(dir) {
    return path.join(__dirname, '..', dir);
}

module.exports = {
    entry: {
        index: ['./src/index.js'],
    },
    output: {
        filename: '[name].bundle.js',
    },
    module: {
        rules: [{
            test: /\.js$/,
            exclude: [resolve('node_modules')],
            loader: 'babel-loader',
            options: {
                cacheDirectory: true
            }
        },
        {
            test: /\.css$/,
            use: [
                'style-loader',
                'css-loader'
            ]
        },]
    },
    plugins: [
        new CleanWebpackPlugin(['dist'], { root: rootPath }),
        new HtmlWebpackPlugin({
            title: 'wind-demo',
            template: 'public/index.html'
        }),
    ],
}